/**
  ******************************************************************************
  * @file 	zbUtils.c 
  * @brief  holds utilities that could be used by any other file 
  ******************************************************************************
  */
  

#include "zbUtils.h"



// data conversion
void u32ToBytes(u32 value, u8 buffer[])
{
	buffer[0] 	=   (u8)((value>>24) & 0xFF);
    buffer[1] 	=   (u8)((value>>16) & 0xFF);
	buffer[2] 	= 	(u8)((value>>8) & 0xFF);
	buffer[3] 	=	(u8)(value & 0xFF);
}

u32 bytesToU32(u8 buffer[])
{
	u32 retU32 = 0;
	u16 high = 0, low = 0;
	high = (((u16)buffer[0])<<8) | buffer[1];
	low = (((u16)buffer[2])<<8) | buffer[3];
	retU32 = (((u32)high)<<16) | low;

	return retU32;
}

u16 bytesToU16(u8 buffer[])
{
	u16 retU16 = 0;
	retU16 = (((u16)buffer[1])<<8) | buffer[0];

	return retU16;
}

